/**
 * Project: ameba.web
 * 
 * File Created at 2015年11月24日
 * $Id$
 * 
 * Copyright 2015 dface.cn Croporation Limited.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * dface Company. ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with www.dface.cn
 */
package cn.dface.ameba.web.controller;

import java.io.IOException;

import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Value;
/**
 * PageController
 * 
 * @author LVZY
 */
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import cn.dface.ameba.toolkit.util.SessionUtils;

@Controller
public class PageController {
    
    @Value("${ucenter.loginUrl}")
    private String ucenterLoginUrl;

    @RequestMapping(value = { "", "/" })
    public String index(ModelMap map, HttpSession session) {
        return "/template/index";
    }

    @RequestMapping(value = "/application/deploy")
    public String getApplicationDeployBackPage(ModelMap map, HttpSession session) {
        map.put("cssName", "application");
        map.put("navlist", new String[] {"运维系统", "应用管理", "部署应用"});
        return "/template/application/deploy/index";
    }
    
    @RequestMapping(value = "/application/api") 
    public String getApplicationApiPage(ModelMap map, HttpSession session){
        map.put("cssName", "application");
        map.put("navlist", new String[] {"运维系统", "应用管理", "API文档"});
        return "/template/application/api/index";
    }
    
    @RequestMapping(value = "/storage")
    public String getStoragePage(ModelMap map, HttpSession session){
        map.put("navlist", new String[] {"运维系统", "存储管理"});
        return "template/storage/index";
    }
    
    @RequestMapping(value = "/logout")
    public void logout(HttpServletResponse response, HttpSession session) {
        session.invalidate();
        try {
            response.sendRedirect(ucenterLoginUrl);
        } catch (IOException e) {
        }
    }
    
    @RequestMapping(value = "login")
    public void login(HttpServletResponse response) {
        try {
            response.sendRedirect(ucenterLoginUrl);
        } catch (IOException e) {
        }
    }
}
